<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新闻公告 - 智慧农业信息管理系统</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f5f7fa;
        }
        .navbar {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .news-card {
            background: white;
            border-radius: 10px;
            padding: 25px;
            margin-bottom: 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            transition: all 0.3s;
            border-left: 4px solid #667eea;
        }
        .news-card:hover {
            box-shadow: 0 5px 20px rgba(0,0,0,0.1);
            transform: translateY(-2px);
        }
        .news-card.top {
            border-left-color: #f5576c;
            background: linear-gradient(to right, #fff5f5, white);
        }
        .news-title {
            font-size: 1.3rem;
            font-weight: 600;
            color: #333;
            margin-bottom: 10px;
        }
        .news-meta {
            color: #999;
            font-size: 0.9rem;
            margin-bottom: 15px;
        }
        .news-content {
            color: #666;
            line-height: 1.6;
            margin-bottom: 15px;
        }
        .badge-top {
            background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
        }
        .badge-type {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container-fluid">
            <a class="navbar-brand" href="/index">🌾 智慧农业管理系统</a>
            <div class="navbar-nav ms-auto">
                <a class="btn btn-outline-light btn-sm" href="/index">返回首页</a>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2>📰 新闻公告</h2>
        </div>
        
        <div th:if="${newsList != null and !newsList.isEmpty()}">
            <div th:each="news : ${newsList}" class="news-card" th:classappend="${news.isTop == 1} ? 'top' : ''">
                <div class="d-flex justify-content-between align-items-start mb-2">
                    <div>
                        <span th:if="${news.isTop == 1}" class="badge badge-top me-2">
                            <i class="fas fa-star me-1"></i>置顶
                        </span>
                        <span class="badge badge-type" th:text="${news.type == 'notice' ? '公告' : (news.type == 'news' ? '新闻' : '活动')}"></span>
                    </div>
                    <span class="news-meta">
                        <i class="far fa-eye me-1"></i><span th:text="${news.viewCount}">0</span> 次浏览
                    </span>
                </div>
                
                <h3 class="news-title" th:text="${news.title}">新闻标题</h3>
                
                <div class="news-meta">
                    <i class="far fa-user me-1"></i><span th:text="${news.author}">作者</span>
                    <span class="ms-3">
                        <i class="far fa-clock me-1"></i>
                        <span th:text="${#temporals.format(news.publishTime, 'yyyy-MM-dd HH:mm')}"></span>
                    </span>
                </div>
                
                <div class="news-content" th:text="${news.content.length() > 200 ? news.content.substring(0, 200) + '...' : news.content}">
                    新闻内容摘要
                </div>
                
                <div class="text-end">
                    <a th:href="@{/news/detail/{id}(id=${news.id})}" class="btn btn-outline-primary btn-sm">
                        阅读全文 <i class="fas fa-arrow-right ms-1"></i>
                    </a>
                </div>
            </div>
        </div>
        
        <div th:if="${newsList == null or newsList.isEmpty()}" class="alert alert-info text-center">
            <i class="fas fa-info-circle me-2"></i>暂无新闻公告
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
</body>
</html>

